import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * User: Bella
 * Date: 4/13/14
 */
public class WebGraph implements Iterable<PageNode> {

   private Map<String,PageNode> webGraph;

    public WebGraph() {
        webGraph= new HashMap<String,PageNode>();
    }

    public void addWebPage (String url, PageNode pageNode) {

        if (!webGraph.containsKey(url))
            //System.out.println("web page already exist");

        webGraph.put(url,pageNode);
    }

    public Map<String,PageNode> getWebGraph() {
        return webGraph;
    }

    @Override
    public Iterator<PageNode> iterator() {
        return webGraph.values().iterator();
    }
    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder("Web Graph:");
        sb.append(System.getProperty("line.separator"));

        for (PageNode pageNode : this) {
            sb.append(pageNode);
            sb.append(System.getProperty("line.separator"));
        }

        return sb.toString();
    }

}


